{% extends "modal_form.html" %}

{% load i18n inventree_extras %}

{% block pre_form_content %}

{% default_currency as currency %}
{% settings_value "PART_INTERNAL_PRICE" as show_internal_price %}

<table class='table table-striped table-condensed table-price-two'>
    <tr>
        <td><strong>{% trans 'Part' %}</strong></td>
        <td>{{ part  }}</td>
    </tr>
    <tr>
        <td><strong>{% trans 'Quantity' %}</strong></td>
        <td>{{ quantity }}</td>
    </tr>
</table>

{% if part.supplier_count > 0 %}
    <h4>{% trans 'Supplier Pricing' %}</h4>
    <table class='table table-striped table-condensed table-price-three'>
    {% if min_total_buy_price %}
    <tr>
        <td><strong>{% trans 'Unit Cost' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_unit_buy_price %}</td>
        <td>Max: {% include "price.html" with price=max_unit_buy_price %}</td>
    </tr>
    {% if quantity > 1 %}
    <tr>
        <td><strong>{% trans 'Total Cost' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_total_buy_price %}</td>
        <td>Max: {% include "price.html" with price=max_total_buy_price %}</td>
    </tr>
    {% endif %}
    {% else %}
    <tr>
        <td colspan='3'>
            <span class='warning-msg'><em>{% trans 'No supplier pricing available' %}</em></span>
        </td>
    </tr>
    {% endif %}
    </table>
{% endif %}

{% if part.bom_count > 0 %}
    <h4>{% trans 'BOM Pricing' %}</h4>
    <table class='table table-striped table-condensed table-price-three'>
    {% if min_total_bom_price %}
    <tr>
        <td><strong>{% trans 'Unit Cost' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_unit_bom_price %}</td>
        <td>Max: {% include "price.html" with price=max_unit_bom_price %}</td>
    </tr>
    {% if quantity > 1 %}
    <tr>
        <td><strong>{% trans 'Total Cost' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_total_bom_price %}</td>
        <td>Max: {% include "price.html" with price=max_total_bom_price %}</td>
    </tr>
    {% endif %}
    {% endif %}
    {% if min_total_bom_purchase_price %}
    <tr>
        <td><strong>{% trans 'Unit Purchase Price' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_unit_bom_purchase_price %}</td>
        <td>Max: {% include "price.html" with price=max_unit_bom_purchase_price %}</td>
    </tr>
    {% if quantity > 1 %}
    <tr>
        <td><strong>{% trans 'Total Purchase Price' %}</strong></td>
        <td>Min: {% include "price.html" with price=min_total_bom_purchase_price %}</td>
        <td>Max: {% include "price.html" with price=max_total_bom_purchase_price %}</td>
    </tr>
    {% endif %}
    {% endif %}

    {% if min_total_bom_price or min_total_bom_purchase_price %}
    {% else %}
    <tr>
        <td colspan='3'>
            <span class='warning-msg'><em>{% trans 'No BOM pricing available' %}</em></span>
        </td>
    </tr>
    {% endif %}
    </table>
{% endif %}

{% if show_internal_price and roles.sales_order.view %}
{% if total_internal_part_price %}
    <h4>{% trans 'Internal Price' %}</h4>
    <table class='table table-striped table-condensed table-price-two'>
        <tr>
            <td><strong>{% trans 'Unit Cost' %}</strong></td>
            <td>{% include "price.html" with price=unit_internal_part_price %}</td>
        </tr>
        <tr>
            <td><strong>{% trans 'Total Cost' %}</strong></td>
            <td>{% include "price.html" with price=total_internal_part_price %}</td>
        </tr>
    </table>
{% endif %}
{% endif %}

{% if total_part_price %}
    <h4>{% trans 'Sale Price' %}</h4>
    <table class='table table-striped table-condensed table-price-two'>
        <tr>
            <td><strong>{% trans 'Unit Cost' %}</strong></td>
            <td>{% include "price.html" with price=unit_part_price %}</td>
        </tr>
        <tr>
            <td><strong>{% trans 'Total Cost' %}</strong></td>
            <td>{% include "price.html" with price=total_part_price %}</td>
        </tr>
    </table>
{% endif %}

{% if min_unit_buy_price or min_unit_bom_price or min_unit_bom_purchase_price %}
{% else %}
<div class='alert alert-danger alert-block'>
    {% trans 'No pricing information is available for this part.' %}
</div>
{% endif %}
<hr>
{% endblock %}
